﻿document.write('<script src="/Auth/GetCity"></script>');
var i,t,to;
function CitySelectInti(IntiObj,TriObj, ToObj) {
    i=IntiObj;
    t=TriObj;
    to= ToObj;
    var cityhtml = "<div id=\"citySelectDiv\" class=\"popWinSelector\"><div class=\"multSelectWin\"><span class=\"closeGray fr\"></span><div class=\"clear\"></div><div class=\"jpList\"><ul class=\"jp-l1 fl\">";
    if (rawCitiesData) {
        for (var i = 0; i < rawCitiesData.length; i++) {
            cityhtml += " <li onclick=\"ProClick(this)\" data-id=\"" + rawCitiesData[i].code + "\"><span title=\"" + rawCitiesData[i].name + "\">" + rawCitiesData[i].name + "</span></li>";
        }
    }
    cityhtml += "  </ul><div class=\"jp-l2 sublist fl\"><ul id=\"CityList\">";
    for (var i = 0; i < rawCitiesData[0].sub.length; i++) {
        cityhtml += " <li onclick=\"CityClick(this)\" data-id=\"" + rawCitiesData[0].sub[i].code + "\" data-goindex=\"" + rawCitiesData[0].sub[i].name + "\">" + rawCitiesData[0].sub[i].name + "</li>";
    }
    cityhtml += "</ul></div><div class=\"clear\"></div></div><div class=\"clear\"></div></div></div>";
   $(IntiObj).append(cityhtml);

}
function cancel() {
    $("#citySelectDiv").hide();
}

function ProClick(obj) {
    for (var i = 0; i < rawCitiesData.length; i++) {
        if ($(obj).attr("data-id") == rawCitiesData[i].code) {
            $(obj).addClass("ant");
            $(obj).siblings().removeClass("ant");
            $("#CityList").html("");
            for (var j = 0; j < rawCitiesData[i].sub.length; j++) {
                $("#CityList").append("<li onclick=\"CityClick(this)\" data-id=\"" + rawCitiesData[i].sub[j].code + "\" data-goindex=\"" + rawCitiesData[i].sub[j].name + "\">" + rawCitiesData[i].sub[j].name + "</li>");
            }
        }
    }
}
function CityClick(obj) {
    $(to).text($(obj).text());
    window.localStorage.LocationCityName = $(obj).text();
    window.localStorage.LocationCityID = $(obj).attr("data-id");
    $(obj).addClass("ant");
    $(obj).siblings().removeClass("ant");
    window.location = "/Home/Index?City=" + window.localStorage.LocationCityID;
}